#ifndef __BASE_CONF_MODULE_H_
#define __BASE_CONF_MODULE_H_

#include <string>
#include <list>
#include "Config.h"

namespace BASE{
	class KeyConf{
		public:
			KeyConf(const std::string & _key):key(_key){
				std::cout << "key is " << key << std::endl;
			}

			virtual ~KeyConf(){

			}

			const std::string & Key(){
				return key;
			}

			virtual void apply() = 0;

		protected:
			std::string key;
	};

	template<typename T, typename TDefault>
	class ValueConf: public KeyConf{
		public:
			ValueConf(const std::string & _key, T & _t, const TDefault & _defval):KeyConf(_key), val(_t), defval(_defval){
				
			}

			void apply() {
				
			}

		private:
			T & val;
			TDefault defval;
	};

	class BindConf: public Singleton<BindConf>{
		public:
			BindConf();

			virtual ~BindConf();

			void initialize(const std::string & configFileName);

			void update();

			void load();

			void bind(const std::string & key, size_t & v, size_t defaultVal);
			void bind(const std::string & key, int & v, int defaultVal);
			void bind(const std::string & key, float& v, float defaultVal);
			void bind(const std::string & key, bool& v, bool defaultVal);
			void bind(const std::string & key, std::string & v, const char * defaultVal);

			void watch(const std::string & key, size_t & v, size_t defaultVal);
			void watch(const std::string & key, int& v, int defaultVal);
			void watch(const std::string & key, float & v, float defaultVal);
			void watch(const std::string & key, bool & v, bool defaultVal);
			void watch(const std::string & key, std::string & v, const char * defaultVal);
			
		private:
			typedef std::list<KeyConf*> BindConfs;
			BindConfs mBindConfs;
			BindConfs mWatchConfs;
	};
}

#endif
